Skip to main content

Create schema.py

schema.py is a file that defines the schema or structure of the input and output data that the model expects and returns, respectively. It is used by the training and inference pipelines to ensure that the data being fed into and output by the model conforms to the specified schema.

The schema defines the data types, shapes, and other properties of the input and output data. It can include information such as the names and descriptions of the input and output fields, their data types (e.g. text, numerical, categorical), the allowed ranges or categories, and whether they are required or optional.

Having a well-defined schema is important for ensuring that the model can be integrated with other systems and applications, as well as for ensuring that the data fed into the model is of the correct format and type. The schema.py file is typically included in the root directory of the custom model and is used by the training and inference code to validate input and output data.

This file will contain the schema of input that will be excepted by your endpoint API. You can modify the below code to match your input schema.

For the below code the schema is List.

from pydantic import BaseModel
from typing import List, Any


class PredictSchema(BaseModel):
data: List[Any]